package com.imooc.security.core.validate.code;

import java.time.LocalDateTime;

/**
 * @Description: 验证码(图形、短信)
 * @author Lord
 * @date 2019年3月25日
 */
public class ValidateCode {

    /* 随机数 . */
    private String code;

    /* 过期时间 . */
    private LocalDateTime expireTime;

    public ValidateCode(String code, int expireIn) {
        this.code = code;
        this.expireTime = LocalDateTime.now().plusSeconds(expireIn);// 当前时间+过期时间
    }

    public ValidateCode(String code, LocalDateTime expireTime) {
        this.code = code;
        this.expireTime = expireTime;
    }

    public boolean isExpried() {
        return LocalDateTime.now().isAfter(expireTime);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }

}
